package wu.mapper;


import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;
import wu.pojo.User_niu;

import java.util.List;
import java.util.Map;

public interface UserNiuMapper {
    void insertUserNiuList(@Param("tableName") String tableName,
                           @Param("list") List<User_niu> list);

    @Select("SELECT niu_id, niu_Ranking, niu_Contestants, niu_School, niu_AC, niu_total_score, niu_time, A_score, B_score, C_score, D_score, E_score, F_score, G_score FROM ${tableName}")
    @Results({
            @Result(property = "niu_id", column = "niu_id"),
            @Result(property = "niu_Ranking", column = "niu_Ranking"),
            @Result(property = "niu_Contestants", column = "niu_Contestants"),
            @Result(property = "niu_School", column = "niu_School"),
            @Result(property = "niu_AC", column = "niu_AC"),
            @Result(property = "niu_total_score", column = "niu_total_score"),
            @Result(property = "niu_time", column = "niu_time"),
            @Result(property = "A_score", column = "A_score"),
            @Result(property = "B_score", column = "B_score"),
            @Result(property = "C_score", column = "C_score"),
            @Result(property = "D_score", column = "D_score"),
            @Result(property = "E_score", column = "E_score"),
            @Result(property = "F_score", column = "F_score"),
            @Result(property = "G_score", column = "G_score")
    })
    List<User_niu> getAllUserNiu(String tableName);

    @Select("SELECT niu_id, niu_Ranking, niu_Contestants, niu_School, niu_AC, niu_total_score, niu_time, A_score, B_score, C_score, D_score, E_score, F_score, G_score FROM ${tableName} WHERE niu_id = #{niuId}")
    @Results({
            @Result(property = "niu_id", column = "niu_id"),
            @Result(property = "niu_Ranking", column = "niu_Ranking"),
            @Result(property = "niu_Contestants", column = "niu_Contestants"),
            @Result(property = "niu_School", column = "niu_School"),
            @Result(property = "niu_AC", column = "niu_AC"),
            @Result(property = "niu_total_score", column = "niu_total_score"),
            @Result(property = "niu_time", column = "niu_time"),
            @Result(property = "A_score", column = "A_score"),
            @Result(property = "B_score", column = "B_score"),
            @Result(property = "C_score", column = "C_score"),
            @Result(property = "D_score", column = "D_score"),
            @Result(property = "E_score", column = "E_score"),
            @Result(property = "F_score", column = "F_score"),
            @Result(property = "G_score", column = "G_score")
    })
    User_niu getUserNiuById(@Param("tableName") String tableName,
                            @Param("niuId") int niuId);

    @Insert("INSERT INTO ${tableName} (niu_id, niu_Ranking, niu_Contestants, niu_School, niu_AC, niu_total_score, niu_time, A_score, B_score, C_score, D_score, E_score, F_score, G_score) VALUES (#{niu_id}, #{niu_Ranking}, #{niu_Contestants}, #{niu_School}, #{niu_AC}, #{niu_total_score}, #{niu_time}, #{A_score}, #{B_score}, #{C_score}, #{D_score}, #{E_score}, #{F_score}, #{G_score})")
    void insertUserNiu(User_niu userNiu, String tableName);

    @Update("UPDATE ${tableName} SET niu_Ranking = #{niu_Ranking}, niu_Contestants = #{niu_Contestants}, niu_School = #{niu_School}, niu_AC = #{niu_AC}, niu_total_score = #{niu_total_score}, niu_time = #{niu_time}, A_score = #{A_score}, B_score = #{B_score}, C_score = #{C_score}, D_score = #{D_score}, E_score = #{E_score}, F_score = #{F_score}, G_score = #{G_score} WHERE niu_id = #{niu_id}")
    void updateUserNiu(User_niu userNiu, String tableName);

    @Delete("DELETE FROM ${tableName} WHERE niu_id = #{niu_id}")
    void deleteUserNiu(int niu_id, String tableName);




}
